{template 'header'}
<style>
.lists{
	width:100%;
	height:auto;
}
.top_img{
	width:30%;
	margin:50px 35% 20px 35%
	;
}
.with_title,.money_tip,.i-tip{
	width:100%;
	height:auto;
	line-height:24px;
	font-size:14px;
	color:#333;
	text-align:center;
}
.width_money{
	width:100%;
	height:50px;
	line-height:50px;
	font-size:14px;
	color:#333;
	text-align:center;
}
.width_money>span{
	font-size:24px;
}
.money_tip{
	color:#01bb94;
}
.with_btn{
	width:40%;
	height:40px;
	line-height:40px;
	margin: 15px 30%;
	border-radius:40px;
	background:#01bb94;
	display:block;
	text-align:center;
	color:#fff;
}
.i-tip{
	width:80%;
	margin:0 10%;
	font-size:12px;
}
.withpic{
	width: 100%;
    display: block;
    text-align: center;
    margin-top: 10px;
}
.withpic>img{
	width:30%;
}
.input{
	width: 60%;
    display: block;
    margin: 10px auto;
    border: 1px solid gainsboro;
    border-radius: 5px;
    padding: 5px;
    text-align: center;
    font-size: 15px;
}
.inputimg{
	position:absolute;
	left:0;
	z-index:3;
	width:30%;
	margin-left:35%;
	-webkit-tap-highlight-color: transparent;
	filter:alpha(Opacity=0); 
	opacity: 0;
}
.layui-layer-molv .layui-layer-title{
	background:#01bb94 !important;
}
.layui-layer-molv .layui-layer-btn a{
	background:#01bb94 !important;
	border-color:#01bb94 !important;
}
</style>

<img class="top_img" src="{$mem['avatar']}" />
<div class="with_title">申请提现</div>
<div class="width_money">
	￥<span>{$mem['credit']}</span>（实际到账：{$real}）
</div>
{if $cfg['commission']['with']>0}<div class="money_tip">金额达到{$cfg['commission']['with']}元方可提现</div>{/if}
{if $mem['credit'] >= $cfg['commission']['with'] && $mem['credit'] > 0}
{if $cfg['commission']['wtype'] && $cfg['commission']['wx_switch']}
<div class="i-tip">{$cfg['commission']['wx_tips']}</div>
	{if $cfg['commission']['wx_switch']==1}
		<span class="withpic">
			<input type="file" name='imgFile1' id='imgFile1' onclick="wapChooseImg();" class="inputimg" value="{if !empty($mem['qr'])}{$mem['qr']}{/if}" />
			<img id="previewImg" src="{if !empty($mem['qr'])}{$mem['qr']}{else}{RES}img/add.png{/if}" />
			<!-- <img id="previewImg" onclick="chooseImg();" src="{if !empty($mem['qr'])}{$mem['qr']}{else}{php echo toimage($cfg['face']['app_add'])}{/if}" /> -->
		</span>
	{/if}
{/if}
<a class="with_btn" onclick="goWith();">提现</a>
{/if}
{if !empty($cfg['commission']['tips'])}<div class="i-tip" style="color:#01bb94;">{$cfg['commission']['tips']}</div>{/if}
{if $cfg['commission']['wrate']>0}<div class="i-tip">平台将收取{$cfg['commission']['wrate']}%的服务费</div>{/if}
{if $cfg['commission']['withnum']>0}<div class="i-tip">每日最多可提现{$cfg['commission']['withnum']}次</div>{/if}
<div style="height:60px;width:100%;"></div>
{template 'loading'}
{template 'footer'}
<script src="{RES}js/ajaxfileupload.js?v={TIMESTAMP}"></script>
<script>
var qrPic = '';
var screenWidth = $(window).width();
var realWidth = screenWidth * 0.3;
$('#imgFile1').css('height',realWidth);
function wapChooseImg(){
	var uploadUrl = "{php echo $this->createMobileUrl('wapuploadpic')}";
	$('input[type=file]').change(function(ie) {
		LOADING(true)
		$.ajaxFileUpload({
	        url: uploadUrl,
	        data: {file: "imgFile1"},
	        secureuri: false, //异步
	        fileElementId: 'imgFile1', //上传控件ID
	        dataType: 'json', //返回的数据信息格式
	        success: function(res, status) {
	        	LOADING(false)
	            if(status != 'success'){
	            	msgTip('上传失败!');
	            }
	            else{
	            	qrPic = res.filename;
	            	$('#previewImg').attr('src',res.filename );
		            $('#imgFile1').val(res.filename );
	            }
	        }
	        /*, error: function(data, status, e) {
	        	layer.close(layerIndex); 
	        	msgTip('上传失败!');
	        }
	        */
	    });
	});
}

{if $cfg['commission']['wtype'] && $cfg['commission']['wx_switch']==1}
	{if empty($mem['qr'])}
	qrPic = '';
	{else}
	qrPic = "{$mem['qr']}";
	{/if}
{/if}
var isSubmit = false;
var defaultPic = "{php echo toimage($cfg['face']['app_add'])}";
function goWith(){
	{if $cfg['commission']['wtype'] && $cfg['commission']['wx_switch'] == 1}
		if(qrPic == ''){
			msgTip('请上传微信收款码');
			return false;
		}
	{/if}
	{if $mem['credit'] <= 0}
	msgTip('暂无可提现金额');
	return false;
	{/if}
	{if $mem['credit'] < $cfg['commission']['with']}
	msgTip('未达到最低提现金额');
	return false;
	{/if}
	if(!confirm('确认要提现吗？')){
		return false;
	}
	if(isSubmit) return false;
	LOADING(true)
	$.ajax({
		type:'post',
		url:"{php echo $this->createMobileUrl('dowith',array('openid'=>$_W['openid']));}",
		data:{qrPic: qrPic},
		success:function(data){
			isSubmit = false;
			LOADING(false)
			data = JSON.parse(data);
			if(data.status==1){
				msgTip(data.msg,function(){
					var url = "{php echo $this->createMobileUrl('my');}";
					location.href = url;
				});
			}
			else{
				msgTip(data.msg);
			}
		}
		,error:function(){
			msgTip('网络错误，请刷新重试');
		}
	});
}
</script>


</body>
</html>
